// 配置路由
// import VueRouter from 'vue-router';
// VueRouter.createRouter();

import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router';

// 定义路由组件(临时)
import HelloWorld from '../components/HelloWorld.vue';
import Login from '../views/Login.vue';
import User from '../views/User.vue';
import UserDetail from '../components/UserDetail.vue';
import UserEdit from '../components/UserEdit.vue';


// 定义路由
const routes = [
    // 路由映射组件
    {
        path: "/", components: {
            default: HelloWorld,
            footer: UserDetail
        }
    },
    { path: "/login", component: Login },
    {
        path: "/user/:username", component: User, props: true
        , children: [
            // { path: '', component: UserDetail },
            {
                path: '/user/detail', // /user/detail
                component: UserDetail
            }, {
                path: 'edit', // /user/:username/edit
                component: UserEdit
            }]
    },
    {
        path: '/redirect', redirect: '/login'
    }
];

// 创建路由对象
const router = createRouter({
    // 传递 `routes` 配置
    routes, // routes: routes 的缩写
    // 使用 `hash` 模式
    history: createWebHashHistory(),
});

// 导出路由对象
export default router;